package converter;

import java.util.Map;

import model.Operator;

import org.apache.struts2.util.StrutsTypeConverter;

import persistency.OperatorRepository;

public class OperatorConverter  extends StrutsTypeConverter{

	
	public Object convertFromString(Map context, String[] values, Class toClass) {
		try{
    	OperatorRepository or = new OperatorRepository();
		return or.getById(new Integer(values[0]));
		}catch(Exception e){
			e.printStackTrace();
		}
		return null;
       
    }

    public String convertToString(Map context, Object o) {
    	Operator op =(Operator)o;
		return ""+op.getOperatorId();
      
    }
    
	
	
	
}
